#!/usr/bin/env bash

set -euo pipefail

# get current path
BASEDIR=$(dirname "$0")

clean_files() {
    CLEARED_FILES=(
        "$HOME/.zshrc.zwc"
        "$HOME/.zcompdump"
        "$HOME/.cache/ctrlp"
        "$BASEDIR/.git/modules"
        "$BASEDIR/main/.antigen/debug.log"
        "$BASEDIR/main/.antigen/init.zsh*"
    )
    for file in ${CLEARED_FILES[@]} ; do

        echo "Remove file $file"
        rm -rf $file
    done
}


uninstall() {

    echo "Undo Stow"
    stow -d $BASEDIR -t $HOME -D main

    echo "Deinit submodules"
    git submodule deinit -f $BASEDIR/main

    echo "Clean files"
    clean_files
}

uninstall
